package hu;

public class thread_two{

    public static void main(String[] args) {
        my_thread th = new my_thread();
        new Thread(th,"A").start();
        new Thread(th,"B").start();
    }
}
class my_thread implements Runnable{
    private static int i = 0;
    @Override
    public void run() {
        while(true){
            synchronized (this){
                notify();
                if(i < 100){
                    System.out.println(Thread.currentThread().getName() + "-->" + ++i);
                }
                else break;
                try {
                    wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
